package com.codexsoft.test;

import org.apache.wicket.extensions.wizard.Wizard;
import org.apache.wicket.markup.html.WebPage;
import java.lang.reflect.Constructor;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 25.08.11
 * Time: 14:10
 * To change this template use File | Settings | File Templates.
 */
public class WizardPage extends WebPage {
    /**
     * Construct.
     *
     * @param <C>
     * @param wizardClass class of the wizard component
     */
    public <C extends Wizard> WizardPage(Class<C> wizardClass) {
        if (wizardClass == null) {
            throw new IllegalArgumentException("argument wizardClass must be not null");
        }
        try {
            Constructor<? extends Wizard> ctor = wizardClass.getConstructor(String.class);
            Wizard wizard = ctor.newInstance("wizard");
            add(wizard);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
